//
//  JZWSliderViewController.m
//  jiangzaiwai
//
//  Created by TomorJM on 2017/8/13.
//  Copyright © 2017年 WF. All rights reserved.
//

#import "JZWSliderViewController.h"
#import "JZWSliderHeaderView.h"
#import "UIViewController+LGSideMenuController.h"

@interface JZWSliderViewController () <UITableViewDelegate, UITableViewDataSource>

@property (nonatomic,strong) UITableView *myTableView;

@property (nonatomic,strong) NSArray *selectItems;

@property (nonatomic,strong) NSArray *selectControllers;

@end

@implementation JZWSliderViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"slider";
    
    self.myTableView = [[UITableView alloc] init];
    _myTableView.delegate = self;
    _myTableView.dataSource = self;
    [self.view addSubview:_myTableView];
    [_myTableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.top.mas_equalTo(self.view);
    }];
    
    
    UIView *baseHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0,250 , JZWSliderHeaderViewHeaderViewHeight)];
    JZWSliderHeaderView *headerView = [[[NSBundle mainBundle] loadNibNamed:@"JZWSliderHeaderView" owner:nil options:nil] lastObject];;
    headerView.frame = CGRectMake(0, 0, 250, JZWSliderHeaderViewHeaderViewHeight);
    [baseHeaderView addSubview:headerView];
    _myTableView.tableHeaderView = baseHeaderView;
    _myTableView.tableFooterView = [UIView new];
    
    
    self.selectItems = @[
                         @[
                             @"我的信息",
                             @"我的实习"
                             ],
                         @[
                             @"我的日志",
                             @"我的足迹",
                             @"用户指南"
                             ],
                         @[
                             @"设置"
                             ]
                         ];
    self.selectControllers = @[
                         @[
                             @"JZWMineInfomationViewController",
                             @"JZWMinePracticeViewController"
                             ],
                         @[
                             @"JZWMineJournalViewController",
                             @"JZWMineFootprintViewController",
                             @"JZWUserGuideViewController"
                             ],
                         @[
                             @"JZWSettingViewController"
                             ]
                         ];
    
}


#pragma mark - TableView datasource

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return _selectItems.count;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    NSArray *arr = _selectItems[section];
    return arr.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *identifier = @"identifier_slider";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
    }
    NSArray *arr = _selectItems[indexPath.section];
    cell.textLabel.text = arr[indexPath.row];
    return cell;
}

#pragma mark - dabaleview delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    UINavigationController *homeNav = (UINavigationController *)self.sideMenuController.rootViewController;
    
    NSArray *arr = _selectControllers[indexPath.section];
    NSString *selectController = arr[indexPath.row];
    [homeNav pushViewController:[[NSClassFromString(selectController) alloc] init] animated:YES];
    [self.sideMenuController hideLeftViewAnimated:YES completionHandler:nil];
}






@end
